
const path = require('path')
const webpack = require('webpack');
const { CleanWebpackPlugin } = require("clean-webpack-plugin");

/**
 *  打包第三方包
 */
module.exports = {
  // mode: 'development',
  // 入口
  entry: {
    axios: 'axios',
    threejs: "three.js"
  },
  // 出口
  output: {
      filename: '[name].dll.js',
      path: path.resolve("./dll"),
      library: '[name]'
  },
  performance: {
    hints:'warning',
    //入口起点的最大体积
    maxEntrypointSize: 50000000,
    //生成文件的最大体积
    maxAssetSize: 30000000,
    //只给出 js 文件的性能提示
    assetFilter: function(assetFilename) {
      return assetFilename.endsWith('.js');
    }
  },
  plugins: [
    new webpack.DefinePlugin({
      'process.env': {
          'NODE_ENV': JSON.stringify('production')
      }
    }),
    new CleanWebpackPlugin({
      cleanOnceBeforeBuildPatterns: ["dll", "manifest"]
    }),
    new webpack.DllPlugin({
      path: path.resolve(__dirname, './manifest/[name].manifest.json'), 
      name: `[name]`,
    }),
    new webpack.DllPlugin({
      path: path.resolve(__dirname, './manifest/[name].manifest.json'), 
      name: `[name]`,
    }),
  ]
} 